﻿#ifndef PATTERNSELECTWIDGET_H
#define PATTERNSELECTWIDGET_H

#include <QWidget>
#include <QDir>
#include <QPushButton>
#include <QLabel>
#include <sstream>

#include "mybutton.h"
#include "items/fileitem.h"
#include "setcontrolstyle.h"
//#include "Include/datafiledst.h"
//#include "Include/datafilecomb.h"
//#include "Include/embdata.h"
#include "datafile/datafiledst.h"
#include "datafile/datafiledsr.h"
#include "datafile/datafilequi.h"
#include "datafile/datafilequix.h"
#include "datafile/hpgl/importhpgl.h"
#include "datafile/dxf/dl_creationadapter.h"
#include "datafile/dxf/dl_dxf.h"
#include "datafile/hank_CreationClass.h"
#include "datafile/dxf_tools.h"
#include "promptdialog.h"
#include <QMouseEvent>
#include <QDateTime>
#include "mctype/mainwidgetfunction.h"

#define EMBALLOWNEEDLELIMIT 2000000  //绣作允许最大针数上限

namespace Ui {
class PatternSelectWidget;
}

class PatternSelectWidget : public QWidget
{
    Q_OBJECT

public:
    explicit PatternSelectWidget(QWidget *parent = 0);
    ~PatternSelectWidget();

private:
    Ui::PatternSelectWidget *ui;
    int m_itemPerPage;//花样选择界面每页图片数

private:
    void initControl();//初始化窗体控件，包括位置、尺寸、样式
    void initResolution();
    void initControlStyle();//初始化窗体控件样式
    
private:
    QString m_firstFilePath;//文件一级目录
    QString m_curFilePath;//当前选择目录
    QList<FileItem> m_fileItemList;//花样选择界面花样文件列表
    
    int m_curPages;//花样选择界面当前页数
    int m_pageNums;//总页数
    int m_selectedPattenIdx;//被选中的花版号

    QList<MyButton*> m_imageButtonList;
    
private:
    void initialize();//初始化
    void initPattern();//初始化花样
    void getDirPatternFiles(QString dirPath);//获取路径下的花样
    void refreshPageUi();//刷新界面显示
    void refreshCheckedPage();//刷新条目选中状态
    void refreshChecked();//刷新条目选中状态
    void clickItem(int idx);//点击花样图片
    void clearFileInfo();//清空花样信息
    void getFileInfo(QString filePath, QString suffix);//获取花样信息
    
public:
    void setTypeLogo(QString tStyle);//设置类型图标
    void setMainTitle(QString str);//设置主title
    void setSubTitle(QString str);//设置副title
    void createCurDirPatterns();//生成当前路径花样

public:
    QSize getImageSize();//获取绘图区域大小
    
private slots:
    //点击图片按钮事件
    void on_buttonImage1_clicked();
    void on_buttonImage2_clicked();
    void on_buttonImage3_clicked();
    void on_buttonImage4_clicked();
    void on_buttonImage5_clicked();
    void on_buttonImage6_clicked();
    void on_buttonImage7_clicked();
    void on_buttonImage8_clicked();
    void on_buttonImage9_clicked();
    void on_buttonImage10_clicked();
    void on_buttonBackUpDir_clicked();
    void on_buttonPgUp_clicked();
    void on_buttonPgDn_clicked();
    void on_buttonOk_clicked();
    void on_buttonCancel_clicked();

signals:
    void siSelectPattern(QString filePath, s16 showFlag = 0);//选择花样并点击确定按钮
     void siPatchPattern(QString filePath,s16 showFlag = 0);//贴补绣花样并点击确定按钮

     //鼠标事件
 protected:
     void mousePressEvent(QMouseEvent *e);
     void mouseReleaseEvent(QMouseEvent *e);

 private:
     int m_mousePressX;
     int m_mousePressY;
     int m_mouseReleaseX;
     int m_mouseReleaseY;

};

#endif // PATTERNSELECTWIDGET_H
